package org.javaboy.vhr.service;

import org.apache.ibatis.annotations.Param;
import org.javaboy.vhr.mapper.EvaluationMapper;
import org.javaboy.vhr.model.Employee;
import org.javaboy.vhr.model.Evaluation;
import org.javaboy.vhr.model.RespPageBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
@Service
public class EvaluationService {
    @Autowired
    EvaluationMapper evaluationMapper;

    public RespPageBean getAllEvaluation(Integer page, Integer size, Evaluation evaluation, Date[] dateScope){
        if (page != null && size != null) {
            page = (page - 1) * size;
        }
        List<Evaluation> data = evaluationMapper.selectAllEvaluationByPage(page,size,evaluation,dateScope);
        Long total = evaluationMapper.count(evaluation,dateScope);
        RespPageBean bean = new RespPageBean();
        bean.setData(data);
        bean.setTotal(total);
        return bean;
    }

    public Integer addEvaluation(Evaluation evaluation){
        int result = evaluationMapper.insert(evaluation);
        return result;
    }

    public Integer updateByEvaluationId(Evaluation evaluation){
        return evaluationMapper.updateByEvaluationId(evaluation);
    }
}
